#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
struct car {
    int d,v,a;
} a[N];
struct seg {
    int l,r;
    bool flag;
} b[N];
int t,n,m,L,V,cnt,tot,p[N];
bool cmp(seg x, seg y) {
    return x.r<y.r;
}
int main() {
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> t;
    while(t--) {
        cin >> n >> m >> L >> V;
        cnt=tot=0;
        for(int i=1; i<=n; i++) {
            cin >> a[i].d >> a[i].v >> a[i].a;
            if(a[i].v<=V && a[i].a<=0) continue;
            if(a[i].v>V && a[i].a>=0) {
                b[++tot]={a[i].d,L};
                continue;
            }
            double tmp,ti;
            tmp=a[i].d+1.0*(V+a[i].v)*(V-a[i].v)/2.0/a[i].a;
            if(a[i].a>0) {
                if(tmp>1.0*L) continue;
                b[++tot]={(int)floor(tmp+1.0),L};
            }
            else {
                b[++tot]={a[i].d,min(L,(int)ceil(tmp-1.0))};
            }
        }
        for(int i=1; i<=m; i++) cin >> p[i];
        sort(p+1,p+m+1);
        for(int i=1; i<=tot; i++) {
            int L=lower_bound(p+1,p+m+1,b[i].l)-p;
            int R=upper_bound(p+1,p+m+1,b[i].r)-p-1;
            if(L<=R) cnt++,b[i].flag=1,b[i].r=p[R];
        }
        cout << cnt << ' ';
        sort(b+1,b+tot+1,cmp);
        int ans=0,lst=-1;
        for(int i=1; i<=tot; i++) {
            if(!b[i].flag) continue;
            if(b[i].l>lst) ans++,lst=b[i].r;
        }
        cout << m-ans << '\n';
    }
    return 0;
}
// Air_Color5 CCCCCCCCCCCCOrz
